package miku.firstgame.constrants
{

	import miku.firstgame.net.ByteArrayEx;
	import miku.firstgame.net.pack.AddRoomResponsePack;
	import miku.firstgame.net.pack.ChangeCurrentTurnResponsePack;
	import miku.firstgame.net.pack.EnterRoomResponsePack;
	import miku.firstgame.net.pack.ExitRoomResponsePack;
	import miku.firstgame.net.pack.GetReadyResponsePack;
	import miku.firstgame.net.pack.GoldCompleteResponsePack;
	import miku.firstgame.net.pack.GoldGameStartResponsePack;
	import miku.firstgame.net.pack.IReceivePack;
	import miku.firstgame.net.pack.LoginResponsePack;
	import miku.firstgame.net.pack.RemoveRoadCardResponsePack;
	import miku.firstgame.net.pack.RemoveRoomResponsePack;
	import miku.firstgame.net.pack.RoomMasterChangedResponsePack;
	import miku.firstgame.net.pack.SeeMapResponsePack;
	import miku.firstgame.net.pack.SendUserACardResponsePack;
	import miku.firstgame.net.pack.SetRoadCardRequestPack;
	import miku.firstgame.net.pack.SetRoadCardResponsePack;
	import miku.firstgame.net.pack.SetToolToUserResponsePack;
	import miku.firstgame.net.pack.TalkResponsePack;
	import miku.firstgame.net.pack.UserEnterRoomResponsePack;
	import miku.firstgame.net.pack.UserExitRoomResponsePack;
	import miku.firstgame.net.pack.UserGetReadyResponsePack;
	import miku.firstgame.net.pack.UserOfflineResponsePack;
	import miku.firstgame.net.pack.UserOnlineResponsePack;

	public class ProtocalConstants
	{
		public static const LOGIN:int = 0x01;

		public static const USER_ONLINE:int = 0x02;
		public static const USER_OFFLINE:int = 0x03;
		public static const USER_EXIT_ROOM:int = 0x04;

		public static const EXIT_ROOM:int = 0x05;
		public static const ADD_ROOM:int = 0x06;
		public static const REMOVE_ROOM:int = 0x07;

		public static const ENTER_ROOM:int = 0x08;
		public static const USER_ENTER_ROOM:int = 0x09;

		public static const TALK:int = 0x0a;

		public static const PING:int = 0x0b;

		public static const ROOM_MASTER_CHANGE:int = 0x0c;

		public static const GET_READY:int = 0x0d;

		public static const USER_GET_READY:int = 0x0f;

		public static const GAME_START:int = 0x10;
		// gold game 
		public static const GOLD_GAME_START:int = 0x11;

		public static const REMOVE_ROAD_CARD:int = 0x12;
		public static const SET_ROAD_CARD:int = 0x13;

		/**
		 * 给用户发送一张卡片
		 */
		public static const SEND_USER_A_CARD:int = 0x14;

		/**
		 * 用户主动抛弃一张卡片
		 */
		public static const USER_DROP_A_CARD:int = 0x15;

		public static const SET_TOOL_TO_USER:int = 0x16;

		public static const CHANGE_CURRENT_TURN:int = 0x17;

		public static const SEE_MAP:int = 0x18;

		public static const GOLD_COMPLETE:int = 0x19;

		public static function getReceivePack(tag:int,
			bytes:ByteArrayEx):IReceivePack
		{
			var result:IReceivePack = null;
			switch (tag)
			{
				case LOGIN:
					result = new LoginResponsePack(bytes);
					break;
				case USER_ONLINE:
					result = new UserOnlineResponsePack(bytes);
					break;
				case USER_OFFLINE:
					result = new UserOfflineResponsePack(bytes);
					break;
				case USER_EXIT_ROOM:
					result = new UserExitRoomResponsePack(bytes);
					break;
				case EXIT_ROOM:
					result = new ExitRoomResponsePack(bytes);
					break;
				case ADD_ROOM:
					result = new AddRoomResponsePack(bytes);
					break;
				case REMOVE_ROOM:
					result = new RemoveRoomResponsePack(bytes);
					break;
				case ENTER_ROOM:
					result = new EnterRoomResponsePack(bytes);
					break;
				case USER_ENTER_ROOM:
					result = new UserEnterRoomResponsePack(bytes);
					break;
				case TALK:
					result = new TalkResponsePack(bytes);
					break;
				case ROOM_MASTER_CHANGE:
					result = new RoomMasterChangedResponsePack(bytes);
					break;
				case GET_READY:
					result = new GetReadyResponsePack(bytes);
					break;
				case USER_GET_READY:
					result = new UserGetReadyResponsePack(bytes);
					break;
				case GOLD_GAME_START:
					result = new GoldGameStartResponsePack(bytes);
					break;
				case SEND_USER_A_CARD:
					result = new SendUserACardResponsePack(bytes);
					break;
				case SET_ROAD_CARD:
					result = new SetRoadCardResponsePack(bytes);
					break;
				case SET_TOOL_TO_USER:
					result = new SetToolToUserResponsePack(bytes);
					break;
				case CHANGE_CURRENT_TURN:
					result = new ChangeCurrentTurnResponsePack(bytes);
					break;
				case GOLD_COMPLETE:
					result = new GoldCompleteResponsePack(bytes);
					break;
				case SEE_MAP:
					result = new SeeMapResponsePack(bytes);
					break;
				case REMOVE_ROAD_CARD:
					result = new RemoveRoadCardResponsePack(bytes);
					break;
			}

			if (null != result)
			{
				result.decode();
			}
			return result;
		}
	}
}
